<!-- 编辑/新建银行 -->
<template>
  <div class=''>
    <dt-modal-edit ref='edit' :title='title' :label-width='100' okText='确定' :width='600'
      @ok='onOk'>
    </dt-modal-edit>
  </div>
</template>

<script>
  import editOpt from '../opt/editOpt'
  import bankApi from '@/biz/buildingManagement/bank'

  export default {
    data() {
      return {
        title: '',
        info: {
          bankName: '',
          subBankName: '',
        }
      };
    },
    methods: {
      show(data) {
        this.info = data
        this.title = data.title
        this.$refs.edit.show(editOpt.options(this), this.info)
      },
      //保存银行
      onOk(data) {
        let params = {
          bankId: this.title == '编辑银行' ? data.bankId : '',
          bankName: data.bankName,
          subBankName: data.subBankName,
          housesId: this.$dt.buildInfo().housesId,
        }
        bankApi.saveOrEditBank(params).then((res) => {
          this.$Message.success(
            `${
                this.title == '编辑银行' ? '银行编辑成功' : '银行创建成功'
              }`
          )
          this.$refs.edit.hide()
          this.$emit('success')
        })
      },
    },
    mounted() {

    },
  }
</script>
<style lang='scss' scoped>

</style>